Skip to content

[APP-899] subquery support for IN filter with unnest columns - #9529

Draft
pjain1 wants to merge 1 commit into
mainfrom
array_subquery_unnest_support
Draft

pjain1 wants to merge 1 commit into
mainfrom
array_subquery_unnest_support

Conversation

@pjain1

@pjain1 pjain1 commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@pjain1 pjain1 changed the title subquery support for IN filter with unnest columns [APP-889] subquery support for IN filter with unnest columns Jun 5, 2026
@pjain1 pjain1 changed the title [APP-889] subquery support for IN filter with unnest columns [APP-899] subquery support for IN filter with unnest columns Jun 5, 2026
@pjain1
pjain1 requested a review from begelundmuller June 5, 2026 15:56

@nishantmonu51 nishantmonu51 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, 👍

@pjain1
pjain1 marked this pull request as draft June 8, 2026 15:08
@nishantmonu51 nishantmonu51 added Type:Bug Something isn't working Area:ClickHouse Size:M Medium change: 100-499 lines labels Jun 30, 2026

@nishantmonu51 nishantmonu51 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I approved this in June, #9582 and #9883 have changed the code it builds on, so I'm moving this to request changes.

  • The ClickHouse branch is unreachable on main. #9582 made ClickHouse's LateralUnnest return auto == true, and the if auto return runs before the new !tupleStyle block. After a rebase, ClickHouse emits arrayJoin("tags") IN (SELECT ...). On ClickHouse 26.3, with rows [a,b], [a,b], [c], [], [d,a] and a subquery returning {a,b}, IN counted the first two rows twice, and NOT IN kept [d,a] while dropping []. The arrayExists form in this PR returned the correct rows, so the approach is right; it just needs to run earlier.
  • #9883 replaced the array-contains API. RequiresArrayContainsForInOperator and GetArrayContainsFunction are gone in favor of ArrayContainsAnyExpression(...) (expr string, ok bool). I suggest adding ArrayContainsSubqueryExpression(arrExpr, subqueryExpr string) (expr string, ok bool) and handling right.Subquery inside writeArrayContainsCondition, returning false, nil when the dialect has no subquery form. DuckDB then falls through to the correlated EXISTS (verified correct on main), ClickHouse gets arrayExists, and Databricks, Snowflake and BigQuery keep main's existing error. When resolving writeSubquery, please keep main's EscapeAlias and ExactMeasures.
  • Tests. The string-only tests stayed green after the branch became dead code. Please add an execution test using in-memory DuckDB and testclickhouse.Start that checks counts for IN and NOT IN on overlapping and empty arrays. Please also update TestUnnestSubqueryFilterSQL, which currently expects DuckDB and ClickHouse to error.

Developed in collaboration with Claude Code

@pjain1

pjain1 commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Is this even needed anymore? if not lets just close it unless someone raises this issue?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area:ClickHouse Size:M Medium change: 100-499 lines Type:Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants